<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.PreparedStatement" %><%--
  Created by IntelliJ IDEA.
  User: Muerzhi
  Date: 2023/12/25
  Time: 20:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
  String reId=request.getParameter("reId");
  String reName=request.getParameter("reName");
  String reAuthor=request.getParameter("reAuthor");
  String reHouse=request.getParameter("reHouse");
  String reMoney=request.getParameter("reMoney");

  Class.forName("com.mysql.cj.jdbc.Driver");
  String url="jdbc:mysql://localhost:3306/library";
  String username="root";
  String password="17876724541";
  Connection conn= DriverManager.getConnection(url,username,password);

  String sql="update book set bookName=?,bookAuthor=?,bookHouse=?,bookMoney=? where bookId=?";
  PreparedStatement ps=conn.prepareStatement(sql);
  ps.setString(1,reName);
  ps.setString(2,reAuthor);
  ps.setString(3,reHouse);
  ps.setString(4,reMoney);
  ps.setString(5,reId);
  int i=ps.executeUpdate();
  if (i !=0){
    out.println("<script>");
    out.println("alert('书籍《"+reName+"》修改成功');");
    out.println("location.href='index.jsp'");
    out.println("</script>");
  }else{
    out.println("<script>");
    out.println("alert('书籍《"+reName+"》修改失败');");
    out.println("location.href='index.jsp'");
    out.println("</script>");
  }
  ps.close();
  conn.close();
%>
</body>
</html>
